package com.ruoyi.livedemo.mapper;

import com.ruoyi.livedemo.entity.UserProfile;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserProfileMapper {

    @Select("SELECT * FROM user_profiles WHERE user_id = #{userId}")
    UserProfile findByUserId(Long userId);

    @Insert("INSERT INTO user_profiles (user_id, self_introduction, job_title, workplace, hobbies, " +
            "partner_name, partner_traits, love_story, contact_wechat, contact_phone) VALUES (#{userId}, #{selfIntroduction}, #{jobTitle}, #{workplace}, #{hobbies}, " +
            "#{partnerName}, #{partnerTraits}, #{loveStory}, #{contactWechat}, #{contactPhone})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(UserProfile profile);

    @Update("UPDATE user_profiles SET self_introduction=#{selfIntroduction}, job_title=#{jobTitle}, workplace=#{workplace}, " +
            "hobbies=#{hobbies}, partner_name=#{partnerName}, partner_traits=#{partnerTraits}, love_story=#{loveStory}, " +
            "contact_wechat=#{contactWechat}, contact_phone=#{contactPhone} WHERE user_id=#{userId}")
    int updateByUserId(UserProfile profile);
}


